package org.softee.functional;

import java.util.Collection;

import org.softee.functional.operation.Function;
import org.softee.functional.operation.Predicate;
import org.softee.functional.operation.ReduceFunction;
import org.softee.functional.operation.Transposal;

public class Sequential<F> extends AbstractFunctional<F> {

    Sequential(Collection<F> inputs) {
        super(inputs);
    }

    @Override
    public Functional<F> sequential() {
        return this;
    }

    @Override
    public ParallelFunctional<F> parallel() {
        return new ParallelSegmented<F>(data);
    }

    @Override
    public F reduce(ReduceFunction<F> reduceFunction) {
        return doReduce(reduceFunction, data);
    }

    @Override
    public Functional<F> filter(Predicate<? super F> predicate) {
        return new Sequential<F>(doFilter(predicate, data));
    }

    @Override
    public <T> Functional<T> map(Function<? super F, ? extends T> function) {
        return new Sequential<T>(doMap(function, data));
    }

    @Override
    public Functional<F> transpose(Transposal<F> transposal) {
        return new Sequential<F>(doTranspose(transposal, data));
    }
}
